package cn.homework.day08;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test10 {
    public static void main(String[] args) {
        Clothes c3 = new Clothes("李宁羽绒服");
        Clothes c1 = new Clothes("阿玛尼背心");
        Clothes c2 = new Clothes("耐克运动裤");
        Clothes c4 = new Clothes("李宁夹克");
        Clothes c5 = new Clothes("阿迪短裤");
        Clothes c6 = new Clothes("安踏篮球裤");
        Clothes c7 = new Clothes("李宁帽子");

        ArrayList<Clothes> list01 = new ArrayList<>();
        ArrayList<Clothes> list02 = new ArrayList<>();
        Collections.addAll(list01, c1, c2, c3, c4);
        Collections.addAll(list02, c5, c6, c7);

        User u01 = new User("zs", list01);
        User u02 = new User("lisi", list02);

        ArrayList<User> users = new ArrayList<>();
        users.add(u01);
        users.add(u02);

        List<Clothes> collect = users.stream().flatMap(new Function<User, Stream<Clothes>>() {
            @Override
            public Stream<Clothes> apply(User user) {

                return user.cs.stream();
            }
        }).collect(Collectors.toList());
        System.out.println(collect);
    }
}
